local hashkey =""
local models = {
	{model = 445, file = 'admiral',},
	{model = 405, file = 'sentinel',},
	{model = 496, file = 'blistac',},
	{model = 422, file = 'bobcat',},
	{model = 402, file = 'buffalo',},
	{model = 418, file = 'moonbeam',},
	{model = 404, file = 'peren',},
	{model = 410, file = 'manana',},
	{model = 478, file = 'walton',},
	{model = 566, file = 'tahoma',},
	{model = 540, file = 'vincent',},
	{model = 439, file = 'stallion',},
	{model = 542, file = 'clover',},
	{model = 549, file = 'tampa',},
	{model = 500, file = 'mesa',},
	{model = 480, file = 'comet',},
	{model = 415, file = 'cheetah',},
	{model = 458, file = 'solair',},
	{model = 507, file = 'elegant',},
	{model = 401, file = 'bravura',},
	{model = 559, file = 'jester',},
	{model = 579, file = 'huntley',},
	{model = 587, file = 'euros',},
	{model = 555, file = 'windsor',},
	{model = 551, file = 'merit',},
	{model = 426, file = 'premier',},
	{model = 529, file = 'willard',},
	{model = 576, file = 'tornado',},
	{model = 400, file = 'landstalker',},
	{model = 451, file = 'turismo',},
	{model = 562, file = 'elegy',},
	{model = 581, file = 'bf400',},
	{model = 522, file = 'nrg500',},
	{model = 541, file = 'bullet',},
	{model = 516, file = 'nebula',},
	{model = 602, file = 'alpha',},
	{model = 589, file = 'club',},
	{model = 477, file = 'zr350',},
	{model = 408, file = 'trash',},
	{model = 605, file = 'sadlerckf',},
	{model = 436, file = 'previon',},
	{model = 424, file = 'bfinject',},
	{model = 411, file = 'infernus',},
	{model = 585, file = 'emperor',},
	{model = 506, file = 'supergt',},
	{model = 603, file = 'phoenix',},
	{model = 429, file = 'banshee',},
	{model = 560, file = 'sultan',},
	{model = 600, file = 'picador',},
	{model = 492, file = 'greenwood',},
	{model = 482, file = 'burrito',},
	{model = 466, file = 'glendale',},
	{model = 527, file = 'cadrona',},
	{model = 526, file = 'fortune',},
	{model = 421, file = 'washington',},
	{model = 558, file = 'uranus',},
	{model = 543, file = 'sadler',},
	{model = 517, file = 'majestic',},
	{model = 546, file = 'intruder',},
	{model = 554, file = 'yosemite',},
	{model = 565, file = 'flash',},
	{model = 474, file = 'hermes',},
	{model = 545, file = 'hustler',},
	{model = 475, file = 'sabre',},
	{model = 495, file = 'sandking',},
	{model = 580, file = 'stafford',},
	{model = 423, file = 'tug',},

};

local function replace(id,file)
	local fN = split(file, ',');
	if File.exists('pojazdy/'..file..'.tPSSM') then
		local raw = File('pojazdy/'..file..'.tPSSM', true);
		local rawData = raw:read(raw.size);
		local rawData = rawData:gsub(hashkey,'');
		EngineTXD(rawData):import(id);
		raw:close();
		raw,rawData = nil,nil;
	end
	if File.exists('pojazdy/'..file..'.dPSSM') then
		local raw = File('pojazdy/'..file..'.dPSSM', true);
		local rawData = raw:read(raw.size);
		local rawData = rawData:gsub(hashkey,'');
		EngineDFF(rawData):replace(id);
		raw:close();
		raw,rawData = nil,nil;
	end
end


addEvent("dataDecode",true)
addEventHandler("dataDecode",localPlayer,function(key --[[,arr]])

	hashkey = key
	--models = arr
	for k,v in pairs(models) do
		replace(v.model, v.file);
	end

end)

addEventHandler('onClientResourceStart', resourceRoot,function()
	triggerLatentServerEvent("queryDataDecode",resourceRoot)
end);